<template>
  <div class="home">首页{{ num }}</div>
</template>

<script>
// @ is an alias to /src
export default {
  name: "HomeView",
  components: {},
  data() {
    return {
      num: 10,
      time: null,
    };
  },
  beforeCreate() {
    // console.log(this);
  },
  created() {
    // console.log(this);
    // let dom = document.querySelector(".home");
    // console.log(dom);
  },
  mounted() {
    let dom = document.querySelector(".home");
    // console.log(dom);
    this.num = 20;
    this.time = setInterval(() => {
      this.num++;
      console.log(this.num);
    }, 1000);
  },
  beforeUpdate() {
    // beforeUpdate 和 update 生命周期，说的是视图更新，并不是数据的更新
    console.log("up触发了");
  },
  beforeDestroy() {
    console.log("销毁之前会触发");
  },
  destroyed() {
    // 页面销毁会触发该函数
    console.log("销毁触发的");
    clearInterval(this.time);
  },
  methods: {
    add() {},
  },
};
</script>
